package com.own.business.system.menu.entity.vo;

import com.own.business.system.menu.entity.po.SystemMenu;
import com.own.component.common.base.entity.vo.BaseVo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * SystemMenuVo
 *
 * @author chenxueli
 * @date 2024-03-31 09:22:58
 */
@Schema(title = "系统菜单" + ConstantBeanSuffix.VO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class SystemMenuVo extends BaseVo<SystemMenu> implements Serializable {

    @Schema(title = "菜单编码")
    private String code;

    @Schema(title = "菜单标题")
    private String title;

    @Schema(title = "父级菜单id")
    private Long parentId;

    @Schema(title = "菜单路径")
    private String path;

    @Schema(title = "菜单图标")
    private String icon;

    @Schema(title = "是否禁用 1=禁用 0=可用")
    private Integer isDisable;

    @Schema(title = "是否显示 1=显示 0=隐藏")
    private Integer isShow;

    @Schema(title = "权限标识")
    private String permission;

    @Schema(title = "排序")
    private Integer sortOrder;

    @Schema(title = "客户端id")
    private String clientId;

    @Schema(title = "菜单链名称")
    private String chainName;

    @Schema(title = "菜单链ids")
    private String chainIds;

    /**
     * 构造方法
     *
     * @param entity 原对象
     */
    public SystemMenuVo(@NonNull SystemMenu entity) {
        super(entity);
        this.code = entity.getCode();
        this.title = entity.getTitle();
        this.parentId = entity.getParentId();
        this.path = entity.getPath();
        this.icon = entity.getIcon();
        this.isDisable = entity.getIsDisable();
        this.isShow = entity.getIsShow();
        this.permission = entity.getPermission();
        this.sortOrder = entity.getSortOrder();
        this.clientId = entity.getClientId();
        this.chainName = entity.getChainName();
        this.chainIds = entity.getChainIds();
    }

    /**
     * 转po对象
     *
     * @param entity 原对象
     * @return po对象
     */
    @Override
    public SystemMenu toPo(SystemMenu entity) {
        if (entity == null) {
            entity = new SystemMenu();
        }
        entity.setCode(this.code);
        entity.setTitle(this.title);
        entity.setParentId(this.parentId);
        entity.setPath(this.path);
        entity.setIcon(this.icon);
        entity.setIsDisable(this.isDisable);
        entity.setIsShow(this.isShow);
        entity.setPermission(this.permission);
        entity.setSortOrder(this.sortOrder);
        entity.setClientId(this.clientId);
        entity.setChainName(this.chainName);
        entity.setChainIds(this.chainIds);
        return super.toPo(entity);
    }

}
